import 'dart:io';

class DiaryEntry {
  final String id;
  final String title;
  final String content;
  final String mood;
  final DateTime date;
  final File? imageUrl;

  DiaryEntry({
    required this.id,
    required this.title,
    required this.content,
    required this.mood,
    required this.date,
    this.imageUrl,
  });

  Map<String, dynamic> toJson() {
    return {
      'id': id,
      'title': title,
      'content': content,
      'mood': mood,
      'date': date.toIso8601String(),
      'imageUrl': imageUrl?.path,
    };
  }

  factory DiaryEntry.fromJson(Map<String, dynamic> json) {
    return DiaryEntry(
      id: json['id'],
      title: json['title'],
      content: json['content'],
      mood: json['mood'],
      date: DateTime.parse(json['date']),
      imageUrl: json['imageUrl'] != null ? File(json['imageUrl']) : null,
    );
  }
}

